package org.myfram.flink.flinkonjar.common.connector.hbase;


import org.apache.flink.connector.hbase.util.HBaseTableSchema;
import org.apache.hadoop.hbase.client.Mutation;

import java.io.Serializable;

public abstract class HBaseTableDefinition<T> implements Serializable {
    private static final long serialVersionUID = 1L;
    private final String tableName;
    private final HBaseTableSchema schema;
    
    protected HBaseTableDefinition(String tableName) {
        this.tableName = tableName;
        this.schema = new HBaseTableSchema();
        defineSchema();
    }
    
    protected abstract void defineSchema();
    
    protected void addColumn(String family, String qualifier, Class<?> clazz) {
        schema.addColumn(family, qualifier, clazz);
    }
    
    public String getTableName() {
        return tableName;
    }
    
    public HBaseTableSchema getSchema() {
        return schema;
    }
    
    public abstract Mutation convertToMutation(T value);
}